import { defineStore} from 'pinia'

const useMainStore = defineStore('main', {
  state: ()=>{
    return {
      title: 'hello pinia',
      time: new Date()
    }
  },
  getters:{
    getCurrentDate:(state)=>{
      let d = state.time;
      return d.getFullYear() +"/" + (d.getMonth()+1) +"/" + d.getDate()+ " "+ d.getHours() +":"+d.getMinutes()+":"+d.getSeconds()
    }
  },
  actions: {
    // acitons的函数，不要写成箭头函数。
    modifyDate(){
      this.time = new Date()
    }
  }
})

export const useCouterStore = defineStore('couter', {
  state: ()=>{
    return {
      count: 11000,
    }
  },
  getters:{},
  actions:{}
})

export default useMainStore;